package com.biz;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.biz.IDepBiz;
import com.po.Dep;
import com.services.daoServices;
import com.dao.*;
@Service("DepBiz")
@Transactional
public class DepBiz implements IDepBiz {
	@Resource(name="daoServices")
	private daoServices daoServices;

	public daoServices getDaoServices() {
		return daoServices;
	}

	public void setDaoServices(daoServices daoServices) {
		this.daoServices = daoServices;
	}

	public List<Dep> findAll() {
		List<Dep> lsdep = daoServices.getDepDAO().findAll();
		for (Dep dep : lsdep) {
			dep.setEnums(dep.getEmps().size());
			dep.setUname(dep.getUname());
			System.out.println("aa-->"+dep.getUname());
		}
		return daoServices.getDepDAO().findAll();
	}

	@Override
	public boolean save(Dep dep) {
		try {
			System.out.println(dep.getUname());
			daoServices.getDepDAO().save(dep);
			return true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

}
